import api from "@/api";
import { PORT } from "../config/servicePort";

/**
 * 获取课程列表
 */
export const getCourseList = (params: any) => api.get(`${PORT}/Courses/getList`, params);

/**
 * 获取类别列表
 */
export const getCategoryList = (params?: any) => api.get(`${PORT}/CourseMenus/getList`, params);
export const updateOrAddCategoryItem = (data?: any) =>
	api.post(`${PORT}/CourseMenus/${data?.course_menus_id ? "edit" : "add"}`, data);

/**
 *  获取形式列表
 */
export const getModalityList = (params?: any) => api.get(`${PORT}/BaseCourseCategory/getList`, params);
export const updateOrAddModalityItem = (data?: any) =>
	api.post(`${PORT}/BaseCourseCategory/${data?.base_course_category_id ? "edit" : "add"}`, data);
export const deleteModalityItem = (data?: any) => api.post(`${PORT}/BaseCourseCategory/del`, data);

/**
 * 课程状态修改
 */
export const updateStatus = (data: any) => api.post(`${PORT}/Courses/updateStatus`, data);

/**
 * 删除课程
 */
export const deleteCourse = (data: any) => api.post(`${PORT}/Courses/del`, data);

/**
 * 新建
 */
export const saveCourseApi = (params: any, type: "add" | "edit" | "draft") => {
	const urlInfo = {
		add: `${PORT}/Courses/add`,
		edit: `${PORT}/Courses/edit`,
		draft: `${PORT}/Courses/saveDrafts`
	};

	return api.post(`${urlInfo[type]}`, params);
};

/**
 * 获取详情接口
 */
export const getCourseDetail = (params: any) => api.get(`${PORT}/Courses/getInfo`, params);

/**
 * 获取banner列表
 */
export const getBannerList = (params?: any) => api.get(`${PORT}/CourseBanners/getList`, params);

/**
 * 新增编辑banner
 */

export const addBanner = (data?: any) => api.post(`${PORT}/CourseBanners/add`, data);

/**
 * 获取中部运营
 */
export const getBanner2List = (params?: any) => api.get(`${PORT}/CourseOperations/getInfo`, params);

export const addBanner2 = (data?: any) => api.post(`${PORT}/CourseOperations/edit`, data);
